﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lola.Servicio;

namespace Lola.Vista.Porteria
{
    public partial class xfrmControlAlcoholemiaAlta : Form
    {
        private String _galpon;
        private String _sector;
        private String _codigoServicio;
        private DTO.Grilla.dtoChoferG _chofer;
        public xfrmControlAlcoholemiaAlta(String galpon, String sector, String codigoServicio, DTO.Grilla.dtoChoferG chofer)
        {
            this._galpon = galpon;
            this._sector = sector;
            this._codigoServicio = codigoServicio;
            this._chofer = chofer;

            InitializeComponent();

            this.txtChoferNombre.Text = _chofer.Apellido.Trim() + ", " + _chofer.Nombre;
            this.txtLegajoChofer.Text = _chofer.Legajo.ToString();
            this.txtServicio.Text = this._codigoServicio;

        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (Sistema.getInstancia().RegistrarControlAlcoholemia(
                _codigoServicio, 
                _chofer.Legajo, 
                (int) this.spnResultado.Value))
            {
                MessageBox.Show(
                       "Control registrado",
                       "Control de Alcoholemia",
                       MessageBoxButtons.OK,
                       MessageBoxIcon.Information);
                this.Dispose();
            }
            else
            {
                MessageBox.Show(
                       "Control NO registrado",
                       "Control de Alcoholemia",
                       MessageBoxButtons.OK,
                       MessageBoxIcon.Error);
            }
        }
    }
}
